package testdemo.service.impl;

import edu.nf.beans.annotations.Component;
import edu.nf.beans.annotations.Inject;
import testdemo.dao.UsersDao;
import testdemo.exception.LoginException;
import testdemo.model.Users;
import testdemo.service.LoginService;

@Component("loginService")
public class LoginServiceImpl implements LoginService{

    @Inject(name = "userDao")
    private UsersDao userDao;

    @Override
    public Users login(Users user) {
        user = userDao.findUser(user.getUserName(), user.getPassword());
        if(user == null){
            throw new LoginException("用户名或密码错误.");
        }
        return user;
    }
}
